#include <iostream>
#include <stdarg.h>
#include <cstring>
using namespace std;

void error(const char*,...);

int main(int argc, char const *argv[])
{
    error("int:\t%d\nchar:\t%c\nstring:\t%s",123,'#',"helloworld");
    return 0;
}

void error(const char* sInfo,...){
    va_list ap;
    va_start(ap,sInfo);

    for (int i = 0; i < strlen(sInfo); i++)
    {
        if (sInfo[i]!='%')
            cout<<sInfo[i];
        else
        {
            i++;
            switch (sInfo[i])
            {
            case 's':
                char* s;
                s=va_arg(ap,char*);
                cout<<s;
                break;
            case 'c':
                int ch;
                ch=va_arg(ap,int);
                cout<<(char)ch;
                break;
            case 'd':
                int n;
                n = va_arg(ap,int);
                cout<<n;
                break;
            }
        }
    va_end(ap);
    }
}
